#ifndef UPGMA_H
#define UPGMA_H

#include <ScoringS2S.h>
#include <NWAlign.h>
#include <SubMatrix.h>
#include <AGPFunction.h>
#include <Alignment.h>
#include <SequenceData.h>
#include <iostream>
#include <math.h>
#include "UpgmaCluster.h"
#include "TreeTools.h"

class upgma
{
public:
	upgma(vector<string>*, Biopool::GapFunction*, Biopool::SubMatrix);
	~upgma();

	UpgmaCluster* getResult();
	vector< vector<Biopool::Align*> > alignments;

private:
	int N;
	double** distances;

	vector<string> sequences;
	vector<UpgmaCluster*> clusters;
	vector< vector<double> > clustersDistances;
	Biopool::SubMatrix sub;
	Biopool::GapFunction* gf;

	UpgmaCluster* result;

	//methods
	void computeDistances();
	void computeAlignments();

	void runUpgma();
	void performOnePass();
	double calculateC2CDistance(UpgmaCluster&, UpgmaCluster&);
};

#endif
